﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hongapo_Model;
using Hongapo_Common;


public partial class sysadmin_Users_useradd : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        AddUser();
    }

    #region 添加系统用户
    private void AddUser()
    {
        Hongapo_Model.Users.MUsers model = new Hongapo_Model.Users.MUsers();
        Hongapo_Services.Users.Users bll = new Hongapo_Services.Users.Users();
        if (!string.IsNullOrEmpty(this.txtUsername.Text) && !string.IsNullOrEmpty(this.txtpwd.Text))
        {
            model.Account = this.txtUsername.Text.Trim();
            model.Password = this.txtpwd.Text.Trim();
            model.Remark = this.txtRemark.Text.Trim();
            model.UserType = TypeConvert.ToInt32(this.ddlRole.SelectedValue);
            model.Isopen = this.chkIsopen.Checked == true ? 1 : 0;
            model.UserName = this.txtName.Text.Trim();
            model.Tel = this.txtTel.Text.Trim();
            model.CreateDate = DateTime.Now;
            int i=bll.Add(model);
            if (i != 0)
            {
                this.Show("新增成功！", "userlist.aspx");
            }
            else
            {
                this.Show("新增失败！");
            }
        }
        else
        {
            this.Show("请填写用户名和密码！");
            return;
        }
    }
    #endregion
}
